package com.bawei.module_move.repo

import com.bawei.lib_common.repo.BaseRepositor
import com.bawei.module_move.api.MoveApiServer
import com.example.movie.entity.MovieTypeEntity
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

class MoveRepository  @Inject constructor(private val apiserver:MoveApiServer){


    //获得一级分类
    suspend fun getMutilType():Flow<List<MovieTypeEntity>>{
        return flow {
            var result=apiserver.getMutilType()
            if(result.code==200){
                emit(result.data)
            }else{
                emit(emptyList())
            }
        }
    }

    //获得二级分类
    suspend fun getMutilTypeByid(pid:Int):Flow<List<MovieTypeEntity>>{
        return flow {
            var result=apiserver.getMutilTypeByPid(pid)
            if(result.code==200){
                emit(result.data)
            }else{
                emit(emptyList())
            }
        }
    }



}